package com.bwie.system.controller;

import com.bwie.common.domain.SysUser;
import com.bwie.common.result.Result;
import com.bwie.system.service.SysUserService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@Log4j2
public class SysUserController {
    @Autowired
    private SysUserService sysUserService;

    @Autowired
    private HttpServletRequest request;

    /**
     * 根据用户名获取用户信息
     * @param username
     * @return
     */
    @GetMapping("selectOneByName/{username}")
    public Result<SysUser> selectOneByName(@PathVariable String username){
        log.info("功能名称：根据用户名获取用户信息，请求url：{}，请求方式：{}，请求参数：{}",request.getRequestURI(),request.getMethod(),username);
        SysUser sysUser=sysUserService.selectOneByName(username);
        Result<SysUser> result = Result.success(sysUser);
        log.info("功能名称：根据用户名获取用户信息，请求url：{}，请求方式：{}，响应结果：{}",request.getRequestURI(),request.getMethod(),result);
        return result;
    }
}
